<!--
 * @Author: wjc
 * @Date: 2025-06-18 09:09:53
 * @LastEditors: wjc
 * @LastEditTime: 2025-09-25 17:06:03
 * @Description: 
-->
<template>
  <NiceMenu
    :accordion="accordion"
    :collapse="collapse"
    :collapse-show-title="collapseShowTitle"
    :default-active="defaultActive"
    :menus="menus"
    :mode="mode"
    :rounded="rounded"
    scroll-to-active
    :theme="theme"
    @open="handleMenuOpen"
    @select="handleMenuSelect"
  />
</template>

<script lang="ts" setup>
  import type { MenuProps } from '@nice/nice-ui'
  import type { MenuRecordRaw } from '@nice/types'

  import { NiceMenu } from '@nice/nice-ui'

  interface Props extends MenuProps {
    menus?: MenuRecordRaw[]
  }

  defineOptions({
    name: 'LayoutMenu',
  })

  const props = withDefaults(defineProps<Props>(), {
    accordion: true,
    menus: () => [],
  })

  const emit = defineEmits<{
    open: [string, string[]]
    select: [string, string?]
  }>()

  function handleMenuSelect(key: string) {
    emit('select', key, props.mode)
  }

  function handleMenuOpen(key: string, path: string[]) {
    emit('open', key, path)
  }
</script>
